home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / wattcp / src / sock_ini.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  960 b   |  44 lines

  1. /*
  2.  * sock_init - easy way to guarentee:
  3.  *    - card is ready
  4.  *    - shutdown is handled
  5.  *    - cbreaks are handled
  6.  *      - config file is read
  7.  *    - bootp is run
  8.  *
  9.  * 0.1 : May 2, 1991  Erick - reorganized operations
  10.  */
  11. #include"capalloc.h"
  12. #include"capstdio.h"
  13. #include <copyright.h>
  14. #include <wattcp.h>
  15. #include <stdlib.h>
  16. #include<dos.h>
  17.  
  18. word _survivebootp = 0;
  19.  
  20. void sock_exit()
  21. {
  22.     tcp_shutdown();
  23. }
  24.  
  25. sock_init()
  26. {
  27.     tcp_init();        /* must precede tcp_config because we need eth addr */
  28.     atexit(sock_exit);    /* must not precede tcp_init() incase no PD */
  29.     tcp_cbrk( 0x10 );    /* allow control breaks, give message */
  30.  
  31.     if (tcp_config( NULL )) {    /* if no config file use BOOTP w/broadcast */
  32.     _bootpon = 1;
  33.     outs("Configuring through BOOTP\n");
  34.     }
  35.  
  36.     if (_bootpon)    /* non-zero if we use bootp */
  37.     if (_dobootp()) {
  38.         outs("BOOTP failed\n");
  39.         if ( !_survivebootp )
  40.         sleep(5);
  41.         exit( 3 );
  42.     }
  43. }
  44.